<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------

namespace app\api\logic;

use app\common\logic\LogicBase;
use \tpfcore\Core;
use think\Validate;

class Activity extends ApiBase
{
    public function spinwin($data = [])
    {
        $prize=[
            ["angle"=>60,"tip"=>"恭喜你中了222元现金优惠劵，赶快联系官方领取吧！"],
            ["angle"=>120,"tip"=>"恭喜你中了学第三项免单优惠劵，赶快联系官方领取吧！"],
            ["angle"=>180,"tip"=>"恭喜你中了333元现金优惠劵，赶快联系官方领取吧！"],
            ["angle"=>240,"tip"=>"恭喜你中了单品现金优惠劵，赶快联系官方领取吧！"],
            ["angle"=>300,"tip"=>"恭喜你中了666元现金优惠劵，赶快联系官方领取吧！"],
            ["angle"=>360,"tip"=>"恭喜你中了第二项半价优惠劵，赶快联系官方领取吧！"]
        ];


        $rand_prize = $prize[array_rand($prize)];

        $realAngle = $data['angle']%360+$rand_prize['angle'];    //真正的度数

        $lastAngle = $realAngle%360;                    //最终度数

        if($lastAngle==0) $lastAngle=360;

        $result = [];

        foreach ($prize as $key => $value) {
            if($value['angle']==$lastAngle){
                $result=$value;
            }
        }
        $result['angle']=$rand_prize['angle'];

        $result['revolution']=3;

        /* 中奖列表 */
        $winning_prize_list=[
            ["nickname"=>"158xxxx3625","content"=>"666元现金优惠劵"],
            ["nickname"=>"135xxxx1158","content"=>"222元现金优惠劵"],
            ["nickname"=>"156xxxx8965","content"=>"单品现金优惠劵"],
            ["nickname"=>"132xxxx2122","content"=>"第二项半价优惠劵"],
            ["nickname"=>"177xxxx6583","content"=>"666元现金优惠劵"],
            ["nickname"=>"158xxxx3502","content"=>"333元现金优惠劵"],
            ["nickname"=>"136xxxx1690","content"=>"学第三项免单优惠劵"],
            ["nickname"=>"137xxxx8740","content"=>"222元现金优惠劵"],
            ["nickname"=>"189xxxx6678","content"=>"单品元现金优惠劵"],
            ["nickname"=>"187xxxx2282","content"=>"666元现金优惠劵"]
        ];
        $result['winning_prize_list']=$winning_prize_list;

        return [0,"success",$result];
    }
}